<template>
  <div>
    <hx-table ref="hxtableComponent"
              :tableItems="tableParam"
              @btn-click="method"
              @selectChange="selectChange"
              @operate-column-click="columnClick"
              @getSelections="getSelections">
    </hx-table>

    <div v-if="dialogDetailVisible">
			<el-dialog id="detailDialog" title='详情' :visible.sync="dialogDetailVisible" :width="'90%'" @close='closeDialog'>
				<template>
					<div>
						<router-view></router-view>
					</div>
				</template>
			</el-dialog>
		</div>
  </div>
</template>

<script>
import HxTable from '@/components/huaxia/HxTable/queryTableCollection'
import searchLabel from './json/searchLabel'
import tableLabel from './json/tableLable'
import cloneDeep from 'lodash/cloneDeep'
import { pureLineLoginDone_SearchRequest } from '@/api/publicRepayment/pureLine.js'

export default {
  components: {
    HxTable
  },
  data() {
    return {
      // addRule: cloneDeep(addRule),
      // viewRule: cloneDeep(addRule),
      radioRusult:{},
      tableParam: {
        isShoweds: {
          // 是否显示集合
          pageIsShow: true, // 分页是否显示
          tableIsShow: 1, // 表格是否显示: 1-显示表格; 0-没有符合搜索条件的单子; 2-队列中没有单子
          isSearch: true, // 搜索框是否显示
          showToolTitle: false,
          isRadio: true
          // tableIsAllChange: true,
        },
        pageHelpers: {
          pageSizes: [10, 20, 30, 40, 50, 100], // 每页条数下拉选项
          pageSize: 10, // 每页条数
          totalSum: 10, // 表格数据总数
          currentPage: 1 // 默认当前页
        },
        tableLables: cloneDeep(tableLabel),
        tableData: [],
        queryTables: {
          queryParas: cloneDeep(searchLabel),
          param: {
            pageNum: 1,
            pageSize: 10
          }
        }
      },
      aaa:{},
      dialogDetailVisible:false,
      detailParams:{}
    }
  },
  created() {
    this.getSearch(this.tableParam.queryTables.param)
  },
   watch: {
    $route(to, from) {

      if( from.path=='/publicRepayment/pureLine/loginDetailDone' && to.path=='/publicRepayment/pureLine/pureLineLogin' ){
        this.dialogDetailVisible = false;
        this.getSearch(this.tableParam.queryTables.param)
      }
    }
  },
  methods: {
    // 监听详情页点击右上角*关闭的时候，路径跳转到列表页
    closeDialog(){
       this.$router.push({name: 'publicRepayment_pureLine_pureLineLogin' })
    },
    // queryTable中select的变化
    selectChange(value, currLabel) {
    },
    /* 弹框中的select变化 */
    dialogSelectChange(value, currLabel) {
    },
    /* 操作栏点击 */
    columnClick(operateType, param) {
    },
    method(key, data) {
      switch (key) {
        case 'search': // 搜索事件
          this.getSearch(data)
          break

        case 'reSet': // 检索重置
          this.tableParam.pageHelpers = {
            pageSizes: [10, 20, 30, 40, 50, 100], // 每页条数下拉选项
            pageSize: 10, // 每页条数
            totalSum: 10, // 表格数据总数
            currentPage: 1 // 默认当前页
          }
          this.tableParam.queryTables.param = {
            pageNum: 1,
            pageSize: 10
          }
          this.getSearch(this.tableParam.queryTables.param)
          break

        case 'current_change': // 当前页数修改
          this.tableParam.pageHelpers.currentPage = data
          this.tableParam.queryTables.param.pageNum = this.tableParam.pageHelpers.currentPage
          this.getSearch(this.tableParam.queryTables.param)
          break

        case 'size_change': // 每页数据条数修改
          this.tableParam.pageHelpers.pageSize = data
          this.tableParam.queryTables.param.pageSize = this.tableParam.pageHelpers.pageSize
          this.getSearch(this.tableParam.queryTables.param)
          break

        case 'contractSerialNo': // 点击合同号
          this.detailParams.amraSerialNo = data.amraSerialNo
          this.detailParams.flowSerialNo = data.flowSerialNo
          this.detailParams.contractSerialNo = data.contractSerialNo
          this.detailParams.flowNo = data.flowNo
					if(this.$route.name == 'publicRepayment_pureLine_loginDetailDone') {
							this.$router.push({
								name: 'publicRepayment_pureLine_pureLineLogin',
								params: this.detailParams
							})
						}
						this.dialogDetailVisible = true;
						this.$router.push({
							name: 'publicRepayment_pureLine_loginDetailDone',
							params: this.detailParams
						});
          break
      }
    },

     //获取单选的值
    getSelections(val){
      console.log(val);
      this.radioRusult = val
    },
    /* 根据条件查找 */
    getSearch(param) {
      param.$vueLoading = true;
      pureLineLoginDone_SearchRequest(param).then(response => {
        if (response.code === '0000'&&response.code !== '8888') {
          if (response.data.records.length > 0) {
            const array = response.data.records
            this.tableParam.isShoweds.tableIsShow = 1
            this.tableParam.isShoweds.pageIsShow = true
            this.tableParam.tableData = array
            this.tableParam.pageHelpers.totalSum = response.data.total
          } else {
            this.tableParam.isShoweds.tableIsShow = 2
            this.tableParam.isShoweds.pageIsShow = false
          }
        } else {

        }
      })
    }
  }
}
</script>

<style scoped>
.dialog{
  border: 1px solid red;
  display: none;
}
.el-tabs__header{
  margin-left:15px !important;
}
</style>
